home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.3 / GetBitmap.3 < prev    next >
Text File  |  1995-07-25  |  17KB  |  331 lines

  1.  
  2.  
  3.  
  4.      TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           Tk_GetBitmap,       Tk_DefineBitmap,        Tk_NameOfBitmap,
  12.           Tk_SizeOfBitmap,   Tk_FreeBitmap,   Tk_GetBitmapFromData   -
  13.           maintain database of single-plane pixmaps
  14.  
  15.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  16.           ####iiiinnnncccclllluuuuddddeeee <<<<ttttkkkk....hhhh>>>>
  17.  
  18.           Pixmap
  19.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((_i_n_t_e_r_p, _t_k_w_i_n, _i_d))))
  20.  
  21.           int                                                           |
  22.           TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp((((_i_n_t_e_r_p, _n_a_m_e_I_d, _s_o_u_r_c_e, _w_i_d_t_h, _h_e_i_g_h_t)        |
  23.  
  24.           Tk_Uid
  25.           TTTTkkkk____NNNNaaaammmmeeeeOOOOffffBBBBiiiittttmmmmaaaapppp((((_d_i_s_p_l_a_y, _b_i_t_m_a_p))))                              |
  26.  
  27.           TTTTkkkk____SSSSiiiizzzzeeeeOOOOffffBBBBiiiittttmmmmaaaapppp((((_d_i_s_p_l_a_y, _b_i_t_m_a_p, _w_i_d_t_h_P_t_r, _h_e_i_g_h_t_P_t_r))))         |
  28.  
  29.           TTTTkkkk____FFFFrrrreeeeeeeeBBBBiiiittttmmmmaaaapppp((((_d_i_s_p_l_a_y, _b_i_t_m_a_p))))                                |
  30.  
  31.      AAAARRRRGGGGUUUUMMMMEEEENNNNTTTTSSSS
  32.           Tcl_Interp      *_i_n_t_e_r_p     (in)      Interpreter to use for
  33.                                                 error reporting.
  34.  
  35.           Tk_Window       _t_k_w_i_n       (in)      Token  for  window  in
  36.                                                 which  the bitmap will
  37.                                                 be used.
  38.  
  39.           Tk_Uid          _i_d          (in)      Description of bitmap;
  40.                                                 see below for possible
  41.                                                 values.
  42.  
  43.           Tk_Uid          *_n_a_m_e_I_d     (in)      Name for new bitmap to
  44.                                                 be defined.
  45.  
  46.           char            *_s_o_u_r_c_e     (in)      Data  for  bitmap,  in
  47.                                                 standard        bitmap
  48.                                                 format.     Must    be
  49.                                                 stored    in    static
  50.                                                 memory   whose   value
  51.                                                 will never change.
  52.  
  53.           unsigned int    _w_i_d_t_h       (in)      Width of bitmap.
  54.  
  55.           unsigned int    _h_e_i_g_h_t      (in)      Height of bitmap.
  56.  
  57.           unsigned int    *_w_i_d_t_h_P_t_r   (out)     Pointer  to  word   to
  58.                                                 fill  in with _b_i_t_m_a_p's
  59.                                                 width.
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/23/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))
  71.  
  72.  
  73.  
  74.           unsigned int    *_h_e_i_g_h_t_P_t_r  (out)     Pointer  to  word   to
  75.                                                 fill  in with _b_i_t_m_a_p's
  76.                                                 height.
  77.  
  78.           Display         *_d_i_s_p_l_a_y    (in)      Display   for    which
  79.                                                 _b_i_t_m_a_p was allocated.   |
  80.  
  81.           Pixmap          _b_i_t_m_a_p      (in)      Identifier    for    a
  82.                                                 bitmap   allocated  by
  83.                                                 TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.
  84.      _________________________________________________________________
  85.  
  86.  
  87.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  88.           These procedures manage a collection of  bitmaps  (one-plane
  89.           pixmaps) being used by an application.  The procedures allow
  90.           bitmaps to be re-used efficiently, thereby  avoiding  server
  91.           overhead,  and also allow bitmaps to be named with character
  92.           strings.
  93.  
  94.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp takes as argument a Tk_Uid describing a bitmap.
  95.           It returns a Pixmap identifier for a bitmap corresponding to
  96.           the  description.   It  re-uses  an  existing   bitmap,   if
  97.           possible,  and  creates a new one otherwise.  At present, _i_d
  98.           must have one of the following forms:
  99.  
  100.           @@@@_f_i_l_e_N_a_m_e           _F_i_l_e_N_a_m_e must be  the  name  of  a  file
  101.                               containing  a  bitmap description in the
  102.                               standard X11 or X10 format.
  103.  
  104.           _n_a_m_e                _N_a_m_e  must  be  the  name  of  a  bitmap
  105.                               defined   previously   with  a  call  to
  106.                               TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp.   The  following  names
  107.                               are pre-defined by Tk:
  108.  
  109.                               eeeerrrrrrrroooorrrr       The  international   "don't"  |
  110.                                           symbol:   a  circle  with  a  |
  111.                                           diagonal line across it.
  112.  
  113.                               ggggrrrraaaayyyy55550000      50%  gray:  a   checkerboard
  114.                                           pattern  where  every  other
  115.                                           bit is on.
  116.  
  117.                               ggggrrrraaaayyyy22225555      25% gray:  a  pattern  where
  118.                                           25%  of  the  bits  are  on,
  119.                                           consisting of  all  the  bit
  120.                                           positions    that   can   be
  121.                                           reached by  a  chess  knight
  122.                                           starting at (0,0).
  123.  
  124.                               hhhhoooouuuurrrrggggllllaaaassssssss   An hourglass symbol.          |
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/23/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))
  137.  
  138.  
  139.  
  140.                               iiiinnnnffffoooo                                           ||
  141.                                           A large letter ``i''.         |
  142.  
  143.                               qqqquuuueeeesssstttthhhheeeeaaaadddd                                      ||
  144.                                           The  silhouette  of  a human  |
  145.                                           head, with a  question  mark  |
  146.                                           in it.                        |
  147.  
  148.                               qqqquuuueeeessssttttiiiioooonnnn                                       ||
  149.                                           A large question-mark.        |
  150.  
  151.                               wwwwaaaarrrrnnnniiiinnnngggg                                        ||
  152.                                           A large exclamation point.
  153.  
  154.  
  155.           Under normal conditions, TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp returns an  identifier
  156.           for  the  requested  bitmap.  If an error occurs in creating
  157.           the bitmap, such as when _i_d refers to a  non-existent  file,
  158.           then  NNNNoooonnnneeee  is  returned  and  an  error  message is left in
  159.           _i_n_t_e_r_p->_r_e_s_u_l_t.
  160.  
  161.           TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp associates a name with in-memory bitmap data  |
  162.           so that the name can be used in later calls to TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.  |
  163.           The _n_a_m_e_I_d argument gives a name for the  bitmap;   it  must  |
  164.           not  previously have been used in a call to TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp.  |
  165.           The arguments _s_o_u_r_c_e, _w_i_d_t_h, and _h_e_i_g_h_t describe the bitmap.  |
  166.           TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp normally returns TCL_OK;  if an error occurs  |
  167.           (e.g. a bitmap named _n_a_m_e_I_d has already been  defined)  then  |
  168.           TCL_ERROR  is  returned  and  an  error  message  is left in  |
  169.           _i_n_t_e_r_p->_r_e_s_u_l_t.  Note:  TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp expects  the  memory  |
  170.           pointed  to by _s_o_u_r_c_e to be static:  TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp doesn't  |
  171.           make a private copy of  this  memory,  but  uses  the  bytes  |
  172.           pointed to by _s_o_u_r_c_e later in calls to TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.
  173.  
  174.           Typically TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp is used by ####iiiinnnncccclllluuuuddddeeee-ing  a  bitmap
  175.           file  directly  into  a  C  program and then referencing the
  176.           variables defined by the file.  For example,  suppose  there
  177.           exists  a  file ssssttttiiiipppp....bbbbiiiittttmmmmaaaapppp, which was created by the bbbbiiiittttmmmmaaaapppp
  178.           program and contains a stipple pattern.  The following  code
  179.           uses TTTTkkkk____DDDDeeeeffffiiiinnnneeeeBBBBiiiittttmmmmaaaapppp to define a new bitmap named ffffoooooooo:
  180.                Pixmap bitmap;
  181.                #include "stip.bitmap"
  182.                Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
  183.                                stip_width, stip_height);
  184.                ...
  185.                bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
  186.           This code causes the bitmap file to be read at  compile-time
  187.           and  incorporates  the bitmap information into the program's
  188.           executable image.  The same bitmap file  could  be  read  at
  189.           run-time using TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp:
  190.                Pixmap bitmap;
  191.                bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 7/23/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))
  203.  
  204.  
  205.  
  206.           The second form is a bit more flexible (the  file  could  be
  207.           modified after the program has been compiled, or a different
  208.           string could be provided to read a different file),  but  it
  209.           is  a  little  slower  and requires the bitmap file to exist
  210.           separately from the program.
  211.  
  212.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp maintains a database of all  the  bitmaps  that
  213.           have  been  created.   Whenever  possible, it will return an
  214.           existing bitmap  rather  than  creating  a  new  one.   This
  215.           approach   can  substantially  reduce  server  overhead,  so
  216.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp should generally be used in preference to  Xlib
  217.           procedures like XXXXRRRReeeeaaaaddddBBBBiiiittttmmmmaaaappppFFFFiiiilllleeee.
  218.  
  219.           The bitmaps returned by TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp are shared, so  callers
  220.           should  never  modify  them.   If  a bitmap must be modified
  221.           dynamically, then it  should  be  created  by  calling  Xlib
  222.           procedures   such   as   XXXXRRRReeeeaaaaddddBBBBiiiittttmmmmaaaappppFFFFiiiilllleeee   or  XXXXCCCCrrrreeeeaaaatttteeeePPPPiiiixxxxmmmmaaaapppp
  223.           directly.
  224.  
  225.           The procedure TTTTkkkk____NNNNaaaammmmeeeeOOOOffffBBBBiiiittttmmmmaaaapppp  is  roughly  the  inverse  of
  226.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.  Given an X Pixmap argument, it returns the _i_d
  227.           that was passed to TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp when the bitmap was created.  |
  228.           _B_i_t_m_a_p  must have been the return value from a previous call  |
  229.           to TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.
  230.  
  231.           TTTTkkkk____SSSSiiiizzzzeeeeOOOOffffBBBBiiiittttmmmmaaaapppp  returns  the  dimensions  of   its   _b_i_t_m_a_p  |
  232.           argument  in  the  words  pointed  to  by  the  _w_i_d_t_h_P_t_r and  |
  233.           _h_e_i_g_h_t_P_t_r arguments.  As with TTTTkkkk____NNNNaaaammmmeeeeOOOOffffBBBBiiiittttmmmmaaaapppp,  _b_i_t_m_a_p  must  |
  234.           have been created by TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.
  235.  
  236.           When a bitmap returned by TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp is no longer  needed,
  237.           TTTTkkkk____FFFFrrrreeeeeeeeBBBBiiiittttmmmmaaaapppp  should be called to release it.  There should
  238.           be exactly one  call  to  TTTTkkkk____FFFFrrrreeeeeeeeBBBBiiiittttmmmmaaaapppp  for  each  call  to
  239.           TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp.   When  a  bitmap is no longer in use anywhere
  240.           (i.e. it has been freed as many times as it has been gotten)
  241.           TTTTkkkk____FFFFrrrreeeeeeeeBBBBiiiittttmmmmaaaapppp  will release it to the X server and delete it
  242.           from the database.
  243.  
  244.  
  245.      BBBBUUUUGGGGSSSS
  246.           In determining whether an existing bitmap  can  be  used  to
  247.           satisfy  a  new  request,  TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp  considers  only the
  248.           immediate value of its _i_d argument.   For  example,  when  a
  249.           file  name  is  passed  to  TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp,  TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp will
  250.           assume it is safe to re-use an existing bitmap created  from
  251.           the  same  file  name:  it will not check to see whether the
  252.           file itself has changed, or whether  the  current  directory
  253.           has  changed,  thereby  causing  the  name  to  refer  to  a
  254.           different file.
  255.  
  256.  
  257.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  258.  
  259.  
  260.  
  261.      PPPPaaaaggggeeee 4444                                          ((((pppprrrriiiinnnntttteeeedddd 7777////22223333////99995555))))
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))              TTTTkkkk (((( ))))               TTTTkkkk____GGGGeeeettttBBBBiiiittttmmmmaaaapppp((((3333))))
  269.  
  270.  
  271.  
  272.           bitmap, pixmap
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.      Page 5                                          (printed 7/23/95)
  328.  
  329.  
  330.  
  331.